# 修复CreditRecordMapper.xml文件问题
# 此脚本会将scms-admin模块中的CreditRecordMapper.xml文件复制到scms-secondclass模块中

Write-Host "===== 修复CreditRecordMapper.xml文件 ====="

# 检查源文件是否存在
$sourceFile = ".\scms-admin\src\main\resources\mapper\secondclass\CreditRecordMapper.xml"
if (-not (Test-Path $sourceFile)) {
    Write-Host "错误: 源文件 $sourceFile 不存在！" -ForegroundColor Red
    exit 1
}

# 创建目标目录
$targetDir = ".\scms-secondclass\src\main\resources\mapper\secondclass"
if (-not (Test-Path $targetDir)) {
    Write-Host "创建目标目录: $targetDir"
    New-Item -Path $targetDir -ItemType Directory -Force | Out-Null
}

# 复制文件
$targetFile = "$targetDir\CreditRecordMapper.xml"
Write-Host "复制文件: $sourceFile -> $targetFile"
Copy-Item -Path $sourceFile -Destination $targetFile -Force

Write-Host "文件复制完成！"

# 清理和重新编译项目
Write-Host "清理和重新编译项目..."
mvn clean compile

# 删除scms-admin中的重复Mapper XML文件
$adminMapperPath = ".\scms-admin\target\classes\mapper\secondclass"
if (Test-Path $adminMapperPath) {
    Write-Host "删除scms-admin中的重复Mapper XML文件..."
    Remove-Item -Path "$adminMapperPath\*.xml" -Force
}

Write-Host "修复完成！请重启系统以应用更改。" 